************************************************************************************************
** Raspberry Pi Hotspot for Projecting Rapture Kit content over captive Wi-Fi in a browser
** No Internet Required
************************************************************************************************

# 2) RKPi5 — Portable Hotspot Instructions (v2.1)

**Objective**
Install, configure, and validate the captive-portal hotspot and local web server on Raspberry Pi OS (Bookworm). Content is served from the Desktop path.

## Prerequisites

* Pi 5 with 128 GB microSD (user `rk-pi5-user`)
* USB with `_rkpi5/*.sh` and `Section*` content
* Internet **only** during Step 1 (package install)

## Install & Configure

### Step 0 — Orchestrate Setup (once)

Copies scripts/content from USB → Desktop, fixes exec/line endings, ensures `index.html`, then runs steps 0→5.

```bash
bash /media/rk-pi5-user/<USB_LABEL>/_rkpi5/setup-golden-master.sh
```

Outputs:

* Log: `~/Desktop/rkpi5-setup.log`
* Scripts: `~/Desktop/scripts` (executable)
* Content: `~/Desktop/rapture_kit` (with `index.html` and USB root files)

### Step 1 — System Check

```bash
cd ~/Desktop/scripts
./0-check-system.sh
```

Verifies model, memory, CPU temp, `~/Desktop/rapture_kit/index.html`, Wi-Fi, and internet.

### Step 2 — Core Installation

```bash
./1-install-core.sh
```

Installs `nginx`, SSL tooling, `apache2-utils`, `curl`, `jq`, `dos2unix`. Creates self-signed cert and admin auth.

### Step 3 — Hotspot Configuration

```bash
./2-configure-hotspot.sh
```

Creates SSID `rapture_kit` (`10.42.0.1/24`) using NetworkManager + dnsmasq. DNS hijack written to both `dnsmasq.d` and `dnsmasq-shared.d`. Priorities set so hotspot is preferred.

### Step 4 — Web Configuration

```bash
./3-configure-web.sh
```

* HTTP (80): captive landing at `http://10.42.0.1/`
* HTTPS (443): `https://rapturekit.com/rapture_kit/` serves from `~/Desktop/rapture_kit` via `alias`
* SPA fallback stays inside the alias (`/rapture_kit/index.html`)
* Ensures parent directory traverse permissions (755) for nginx
* Redirects `/rapture_kit` → `/rapture_kit/`

### Step 5 — Finalize

```bash
./4-finalize-golden-master.sh
```

Enables services at boot, makes hotspot preferred, disables client auto-connect.

### Step 6 — Validate

```bash
./5-validate-deployment.sh
```

Checks hotspot mode/IP, nginx & NM status, DNS hijack presence, `/health` endpoints, content stats, SSL expiry.

## Operator Test

1. `sudo reboot` (wait ~60 s)
2. Join **`rapture_kit`** (open)
3. Captive page → **Enter Training Portal** → accept SSL warning
4. Browse the portal

## Common Issues & Fixes

* **No captive page**: open `http://10.42.0.1/`; re-run hotspot step if needed.
* **Enter → error**: ensure `index.html` at content root; re-run web step to refresh nginx site.
* **Large media slow**: first-time caching expected; nginx supports range requests.  

---

